package io.renren.modules.sys.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.DeviceCabinetLogDao;
import io.renren.modules.sys.entity.DeviceCabinetLogEntity;
import io.renren.modules.sys.service.DeviceCabinetLogService;


@Service("deviceCabinetLogService")
public class DeviceCabinetLogServiceImpl extends ServiceImpl<DeviceCabinetLogDao, DeviceCabinetLogEntity> implements DeviceCabinetLogService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<DeviceCabinetLogEntity> page = this.page(
                new Query<DeviceCabinetLogEntity>().getPage(params),
                new QueryWrapper<DeviceCabinetLogEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils queryPageInfo(Map<String, Object> params) {
        String qrCode = (String) params.get("qrCode");
        IPage<DeviceCabinetLogEntity> page = this.page(
                new Query<DeviceCabinetLogEntity>().getPage(params),
                new QueryWrapper<DeviceCabinetLogEntity>()
                .eq(StringUtils.isNotBlank(qrCode),"QR_CODE", qrCode)
        );

        return new PageUtils(page);
    }
}
